<?php
App::uses('Naplo', 'Model');

class NaploTest extends CakeTestCase {
	public $fixtures = array('app.naplo', 'app.naplotipus');
	
	public function setUp() {
		parent::setUp();
		$this->Naplo = ClassRegistry::init('Naplo');	//ezzel biztosítjuk, hogy használja az AB kapcsolatot
	}
	
	public function testIsStrValidId(){
		$actual = $this->Naplo->isValidId('STR');
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testIs0ValidId(){
		$actual = $this->Naplo->isValidId(0);
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testIs3ValidId(){
		$actual = $this->Naplo->isValidId(3);
		$expected = array('Naplo' => array('id' => 3,'ceg_id' => 2,'naplotipus_id' => 2,'valuta_id' => 1,'ev' => 2012,'sorszam' => 1,'nev' => 'KHB','alapertelmezett_osztaly' => 0,'alapertelmezett_szamla' => 6,'lezart' => 0));
		$this->assertEquals($expected, $actual);
	}

	public function testGetOsztalyIdForNaploNull(){
		$actual = $this->Naplo->getOsztalyId();
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetOsztalyIdForNaplo4(){
		$actual = $this->Naplo->getOsztalyId(4);
		$expected = 5;
		$this->assertEquals($expected, $actual);
	}

	public function testGetValutaIdForNaploNull(){
		$actual = $this->Naplo->getValutaId();
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetValutaIdForNaplo2(){
		$actual = $this->Naplo->getValutaId(2);
		$expected = 1;
		$this->assertEquals($expected, $actual);
	}

	public function testGetSzamlaForNaploNull(){
		$actual = $this->Naplo->getSzamla();
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetSzamlaForNaplo2(){
		$actual = $this->Naplo->getSzamla(2);
		$expected = 5;
		$this->assertEquals($expected, $actual);
	}

	public function testGetSzamlaForNaploVegyes(){
		$actual = $this->Naplo->getSzamla(6);
		$expected = false;
		$this->assertEquals($expected, $actual);
	}
	
	public function testGetNaploNull(){
		$actual = $this->Naplo->getNaplo();
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetNaploMissingParams(){
		$actual = $this->Naplo->getNaplo(2);
		$expected = false;
		$this->assertEquals($expected, $actual);

		$actual = $this->Naplo->getNaplo(2,1);
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetNaploNonExistence(){
		$actual = $this->Naplo->getNaplo(100,100,100);
		$expected = false;
		$this->assertEquals($expected, $actual);
	}

	public function testGetNaploExistence(){
		$actual = $this->Naplo->getNaplo(5, 1, 2012);
		$expected = array('id' => 4,'ceg_id' => 5,'naplotipus_id' => 1,'valuta_id' => 1,'ev' => 2012,'sorszam' => 3,'nev' => 'Szociális','alapertelmezett_osztaly' => 5,'alapertelmezett_szamla' => 10,'lezart' => 0);
		$this->assertEquals($expected, $actual);
	}
	
	public function testGetVegyesId(){
		$actual = $this->Naplo->getVegyesId(array('ev' => 2012, 'cegId' => 2));
		$expected = 6;
		$this->assertEquals($expected, $actual);
	}	

	public function testGetEv(){
		$actual = $this->Naplo->getEv(1);
		$expected = 2012;
		$this->assertEquals($expected, $actual);
	}	

	public function testGetNaploId(){
		$actual = $this->Naplo->getNaploId(6, 2012);
		$expected = 3;
		$this->assertEquals($expected, $actual);
	}

}
?>